var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = cc._decorator,
    s = r.ccclass,
    c =
        (r.property,
        r.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.parentNode = null;
                e.listNode = [];
                e.canSort = !1;
                e.isOpenScale = !1;
                return e;
            }
            e.prototype.onEnable = function () {
                this.checkOpenView();
            };
            e.prototype.onDestroy = function () {
                console.log("SortChild -------------onDestroy---- " + this.node.name);
            };
            e.prototype.onDisable = function () {};
            e.prototype.starCheckSort = function () {
                this.canSort = !0;
                this.checkOpenView();
            };
            e.prototype.update = function () {
                if (this.isOpenScale && this.parentNode) {
                    for (var t = 0; t < this.listNode.length; t++)
                        this.listNode[t] && (this.listNode[t].scale = this.node.scale);
                    1 == this.node.scale && (this.isOpenScale = !1);
                }
            };
            e.prototype.checkOpenView = function () {
                if (!this.parentNode) {
                    this.parentNode = this.node.parent;
                    for (var t = 0; t < this.node.childrenCount; t++) this.listNode.push(this.node.children[t]);
                }
                if (this.parentNode && this.canSort && this.node.active)
                    for (t = 0; t < this.listNode.length; t++)
                        if (cc.isValid(this.listNode[t])) {
                            var e = this.listNode[t].convertToWorldSpaceAR(cc.Vec2.ZERO);
                            this.listNode[t].parent = this.parentNode;
                            this.listNode[t].setPosition(this.parentNode.convertToNodeSpaceAR(e));
                            ParseTool.setSortIndex(this.listNode[t]);
                            this.isOpenScale = !0;
                        }
            };
            e.prototype.resetToStartPos = function () {
                if (this.parentNode) {
                    this.canSort = !1;
                    this.isOpenScale = !1;
                    for (var t = 0; t < this.listNode.length; t++)
                        if (this && cc.isValid(this.listNode[t]) && this.listNode[t] && this.listNode[t].parent) {
                            var e = this.listNode[t],
                                o = e.convertToWorldSpaceAR(cc.Vec2.ZERO);
                            e.parent = this.node;
                            e.setPosition(this.node.convertToNodeSpaceAR(o));
                        }
                    this.listNode.length = 0;
                    this.parentNode = null;
                }
            };
            return n([s], e);
        })(cc.Component));
o.default = c;
